//
//  AboutUsDetailViewController.m
//  PlayBall
//
//  Created by superman on 14-8-27.
//
//

#import "AboutUsDetailViewController.h"
#import "UIFitButton.h"

@interface AboutUsDetailViewController ()
{
    UIWebView *myWebView;
}

@end

@implementation AboutUsDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
    customLab.backgroundColor = [UIColor clearColor];
    [customLab setText:@"关于玩球球"];
    customLab.textAlignment = NSTextAlignmentCenter;
    [customLab setTextColor:[UIColor whiteColor]];
    customLab.font = [UIFont systemFontOfSize:19];
    self.navigationItem.titleView = customLab;    
    
    if (IOS7) {
        myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.  size.width, self.view.frame.size.height-64)];
    }else{
        myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.  size.width, self.view.frame.size.height-44)];
    }
    
    myWebView.delegate = self;
    myWebView.scalesPageToFit = YES;
    [self.view addSubview:myWebView];
}

#pragma mark 点击事件
- (void)leftBtnClicked:(UIButton *)button
{
//    if (myWebView.canGoBack) {
//         NSLog(@"============%d",myWebView.pageCount);
//        if (myWebView.loading) {
//            [myWebView stopLoading];
//        }
//        [myWebView goBack];
//    }else if(myWebView.pageCount == 0){
//        [self.navigationController popViewControllerAnimated:YES];
//    }
     [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark  WebViewDelegate的协议方法
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [JddCommonFunction setWaitingViewHidden:NO fromController:self];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [JddCommonFunction setWaitingViewHidden:YES fromController:self];
}

- (void)viewWillAppear:(BOOL)animated
{
    NSURL *url = [NSURL URLWithString:self.url];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [myWebView loadRequest:req];
    
}
- (void)viewDidDisappear:(BOOL)animated
{
    [myWebView loadHTMLString:@"" baseURL:nil];
}
- (void)viewWillDisappear:(BOOL)animated
{
   // [myWebView loadHTMLString:@"" baseURL:nil];
    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
